home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of BackSigmoidAxon with adaptible slope
-
- #include "NSDLL.h"
-
- /********************************/
- /* Backpropagation of component */
-
- __declspec(dllexport) void performBackBiasAxon(
- DLLData *instance, // Pointer to instance data
- DLLData *dualInstance, // Pointer to the forward axons instance data
- NSFloat *data, // Pointer to the layer of processing elements (PEs)
- int rows, // Number of rows of PEs in the layer
- int cols, // Number of columns of PEs in the layer
- NSFloat *error, // Pointer to the sensitivity vector
- NSFloat *gradient // Pointer to the bias gradient vector
- )
-
- {
- int i,length=rows*cols;
- NSFloat *beta = getWeights(dualInstance);
- NSFloat *betaGradient = getWeights(instance);
-
- for (i=0; i<length; i++) {
- error[i] *= beta[i]*(data[i]*(1.0f-data[i]) + 0.1f);
- if (gradient)
- gradient[i] += error[i];
- if (betaGradient)
- betaGradient[i] += error[i]*data[i];
- }
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
-
- __declspec(dllexport) DLLData *allocBackBiasAxon(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- DLLData *dualInstance, // Pointer to forward axonÆs instance data (may be NULL)
- int rows, // Number of rows of PEs in the layer
- int cols // Number of columns of PEs in the layer
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- setWeights(instance, rows*cols);
- return instance;
- }
-
- __declspec(dllexport) void freeBackBiasAxon(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
-
-